package net.chowda.castcluster.action;

import net.chowda.castcluster.util.CastClusterConfig;
import net.sourceforge.stripes.action.DefaultHandler;
import net.sourceforge.stripes.action.ForwardResolution;
import net.sourceforge.stripes.action.Resolution;

public class ConfigAction extends BaseAction {
    private String baseUrl;
    private String converterBase;

    @DefaultHandler
    public Resolution showConfig() {
        CastClusterConfig config = CastClusterConfig.getInstance();
        baseUrl = config.getGlobalProp(CastClusterConfig.BASE_URL);
        converterBase = config.getGlobalProp(CastClusterConfig.CONVERTER_PATH);

        // set some defaults.
        if(baseUrl == null)         baseUrl = "http://localhost:8080/castcluster";
        if(converterBase == null)   converterBase = "/Applications/ffmpegX.app/Contents/Resources/ffmpeg";
        return new ForwardResolution("/view/config_edit.jsp");
    }

    public String getBaseUrl() {
        return baseUrl;
    }

    public void setBaseUrl(String baseUrl) {
        this.baseUrl = baseUrl;
    }

    public String getConverterBase() {
        return converterBase;
    }

    public void setConverterBase(String converterBase) {
        this.converterBase = converterBase;
    }
}
